package com.ynny.dao;

import com.ynny.bean.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;

import java.util.List;

public class UserManageImpl implements UserManage{
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Override
    public boolean login(User user) {
        String sql = "select * from users where number=?and password=? and identity=?";
        Object[] obj = new Object[]{user.getNumber(),user.getPassword(),user.getIdentity()
        };
        RowMapper<User>rowMapper;
        rowMapper = new BeanPropertyRowMapper<User>(User.class);
        List<User>user_db = jdbcTemplate.query(sql,rowMapper,obj);
        if(!user_db.isEmpty()){
            return true;
        }
        return false;
    }


    @Override
    public void quit() {
        System.out.println("退出系统");

    }
}
